package com.funo.logic.service;

import cn.hutool.json.JSONUtil;
import com.funo.logic.model.RequestParameter;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RequestParameterService extends AbstractService {


    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 根据所属节点id查询
     * @param belongNodeId
     * @return RequestParameter
     * @since 2024年7月24日15:24:52
     */
    public List<RequestParameter> getByBelongNodeId(String belongNodeId) {
        String value = stringRedisTemplate.opsForValue().get(getCacheKey(belongNodeId));
        return StringUtils.isNotBlank(value) ? JSONUtil.parseArray(value).toList(RequestParameter.class) : null;
    }

    @Override
    public String getCachePrefix() {
        return "requestParameter:";
    }
}
